package cn.com.action;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import cn.com.dao.baseDao;
import cn.com.dao.imp.baseDaoImp;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private String user;
	private String pass;

	private List myList1;
	private List myList2;
	private List myList3;

	// //简单的，未考虑编码的
	// public String execute(){
	// if("11".equals(user) && "11".equals(pass)){
	// return SUCCESS;
	// }else{
	// return ERROR;
	// }
	// }

	// //考虑编码的。单个处理。也可以做一个过滤器来设置
	// public String execute() throws UnsupportedEncodingException{
	// String sssd =
	// java.net.URLDecoder.decode(this.user.getBytes("UTF-8").toString(),"GB2132").toString();
	// System.out.print(user);
	// String ss = this.user.getBytes("UTF-8").toString();
	// System.out.print(user);
	// ActionContext context=ActionContext.getContext();
	// Map parameterMap=context.getParameters();
	// String testUser = parameterMap.get("user").toString();
	// if("你好dd1".equals(user) && "11".equals(pass)){
	// return SUCCESS;
	// }else{
	// return ERROR;
	// }
	// }

	public String execute() throws UnsupportedEncodingException {
		baseDao dao = new baseDaoImp();
		myList1 = new ArrayList();
		myList1.add("1");
		myList1.add("2");
		myList1.add("3");

		myList2 = new ArrayList();
		myList2.add("a");
		myList2.add("b");
		myList2.add("c");

		myList3 = new ArrayList();
		myList3.add("A");
		myList3.add("B");
		myList3.add("C");
		Object obj = dao.get("select * from user where user_name ='" + user
				+ "' " + " and pass_word = '" + pass + "'");
		if (obj != null) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	public String getUser() {
		return user;
	}

	public String getPass() {
		return pass;
	}

	public List getMyList1() {
		return myList1;
	}
	public List getMyList2() {
		return myList2;
	}
	public List getMyList3() {
		return myList3;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}
}
